//
//  ViewController.swift
//  AnimationDemo
//
//  Created by 李明明 on 16/1/28.
//  Copyright © 2016年 李明明. All rights reserved.
//

import UIKit

class ViewController: UIViewController {
    var height: CGFloat = 15
    override func viewDidLoad() {
        super.viewDidLoad()
        let loadingView = LLoadingView(frame: CGRectMake(0, 0, 25, 25), view: view)
        loadingView.cycleTime = 1
        loadingView.bgView.backgroundColor = UIColor.grayColor()
        // 50s 后消失
        let delayTime = dispatch_time(DISPATCH_TIME_NOW, Int64(50 * Double(NSEC_PER_SEC)))
        dispatch_after(delayTime, dispatch_get_main_queue()) { () -> Void in
            loadingView.stopLoading()
        }
        let circle1 = LCircleView(frame: CGRectMake(10, 30, 20, height))
        view.addSubview(circle1)
        let delayTime1 = dispatch_time(DISPATCH_TIME_NOW, Int64(circle1.duration * 0.5 * Double(NSEC_PER_SEC)))
        dispatch_after(delayTime1, dispatch_get_main_queue()) { () -> Void in
            let circle2 = LCircleView(frame: CGRectMake(30, 30, 20, self.height))
            self.view.addSubview(circle2)
        }
        let delayTime2 = dispatch_time(DISPATCH_TIME_NOW, Int64(circle1.duration * Double(NSEC_PER_SEC)))
        dispatch_after(delayTime2, dispatch_get_main_queue()) { () -> Void in
            let circle3 = LCircleView(frame: CGRectMake(50, 30, 20, self.height))
            self.view.addSubview(circle3)
        }
    }
    func addView(var rect: CGRect) {
        rect = CGRectMake(30, 30, 20, self.height)
        let circle = LCircleView(frame: rect)
        self.view.addSubview(circle)
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()

    }
}

